using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;

namespace Game.Core
{
	public class UIEventSystem : EventTrigger
	{
		public delegate void VoidDelegate(GameObject go);

		public static UIEventSystem Get(GameObject go)
		{
			UIEventSystem uIEventSystem = go.GetComponent<UIEventSystem>();
			if (uIEventSystem == null)
			{
				uIEventSystem = go.AddComponent<UIEventSystem>();
			}
			return uIEventSystem;
		}

		public static void ClearEvents(GameObject go)
		{
			UIEventSystem component = go.GetComponent<UIEventSystem>();
			if (component != null)
			{
				component.triggers.Clear();
			}
		}

		public void AddEventListener(EventTriggerType evtType, UnityAction<BaseEventData> callBack)
		{
			Entry entry = new Entry();
			entry.eventID = evtType;
			entry.callback.AddListener(callBack);
			if (base.triggers == null)
			{
				base.triggers = new List<Entry>();
			}
			base.triggers.Add(entry);
		}
	}
}
